package com.mc.lp.database.dao.impl;

import java.util.ArrayList;
import java.util.List;

import org.hibernate.Criteria;
import org.hibernate.criterion.Restrictions;
import org.springframework.dao.DataAccessException;
import org.springframework.stereotype.Repository;

import com.mc.lp.database.dao.ISportRecordDAO;
import com.mc.lp.database.entity.SportsRecordEntity;
/*
 * @author aphanda
 * @date Sep 21, 2014
 * @time 1:11:52 AM
 */

@Repository
public class SportsRecordDAOImpl extends
		AbstractGenericHibernateDAO<SportsRecordEntity, Long, ISportRecordDAO> implements
		ISportRecordDAO {

	/**
	 * 
	 */
	private static final long serialVersionUID = 6673848021523583843L;

	@Override
	public List<SportsRecordEntity> fetchDetailsByEntityIdGrade(Long entityId, int gradeId) {
		List<SportsRecordEntity> acadList = new ArrayList<SportsRecordEntity>();
		Criteria crit = this.getCurrentSession().createCriteria(SportsRecordEntity.class);
		crit.add(Restrictions.eq("gradeId", gradeId));
		crit.add(Restrictions.eq("studentEntity", entityId));
		acadList = (List<SportsRecordEntity>) crit.list();
		return acadList;

	}

	@Override
	public void saveSports(SportsRecordEntity e) {

	}

	

	@Override
	public List<SportsRecordEntity> fetchDetailsByEntityId(Long entityId) {
		// TODO Auto-generated method stub
		List<SportsRecordEntity> acadList = new ArrayList<SportsRecordEntity>();
		Criteria crit = this.getCurrentSession().createCriteria(SportsRecordEntity.class);
		crit.add(Restrictions.eq("studentEntity", entityId));
		acadList = (List<SportsRecordEntity>) crit.list();
		return acadList;
	}

	
	
	@Override
	public List<SportsRecordEntity> fetchSportsByGrades(Long studentEntity, List<Integer> gradeValueList) throws DataAccessException {
		List<SportsRecordEntity> acadList = new ArrayList<SportsRecordEntity>();
		Criteria crit = getCurrentSession().createCriteria(SportsRecordEntity.class);
		crit.add(Restrictions.in("gradeId", gradeValueList));
		crit.add(Restrictions.eq("studentEntity",studentEntity));
		acadList = crit.list();
		return acadList;
	}
}
